package PhaseThirdModuleOne;


import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.mapreduce.Reducer;

import java.io.IOException;

public class Task01Reducer extends Reducer<LongWritable, LongWritable, LongWritable, LongWritable> {
    //定义LongWritable类型的引用指向该类的对象，代表数字大小的排名
    LongWritable rank = new LongWritable(0);

    @Override
    protected void reduce(LongWritable num, Iterable<LongWritable> values, Context context) throws IOException, InterruptedException {

        for (LongWritable value : values) {
            //遍历一次,排名数字加一
            rank = new LongWritable(rank.get()+value.get());
            //将排名rank和数字num输出
            context.write(rank, num);
        }
    }
}
